package com.xzx.mr.index;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

/**
 * @author xinzhixuan
 * @version V1.0
 * @date 2019/8/9 21:42
 */
public class TwoIndexReducer extends Reducer<Text, Text, Text, Text> {
    private Text v = new Text();

    @Override
    protected void reduce(Text key, Iterable<Text> values, Context context) throws IOException,
            InterruptedException {
        StringBuilder builder = new StringBuilder();
        for (Text value : values) {
            builder.append(value.toString().replace("\t", "-->")).append("\t");
        }
        v.set(builder.toString());
        context.write(key, v);
    }
}
